package com.huobao.yunying.adapters;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.huobao.yunying.activitys_hehuoren.Act_Dailipin_Liuyan_detail;
import com.huobao.yunying.entity.LiuyanList;
import com.huobao.zhangying.R;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_Daili_liyan extends QuickAdapter<LiuyanList> {

	public Adapter_Daili_liyan(Context context) {
		super(context, R.layout.item_daili_list);
	}

	@Override
	protected void convert(BaseAdapterHelper helper, final LiuyanList data) {
		String time = data.add_time;
		if(time == null || time.equals("") || time.equals("null")){
			time = "";
		}else{
			try {
				long t = Long.parseLong(time) * 1000;
				time = new SimpleDateFormat("yyyy-MM-dd").format(new Date(t));
			} catch (Exception e) {
			}
		}
		helper.setText(R.id.tv_name, data.goods_name).setText(R.id.tv_tel, time).setOnClickListener(R.id.tv_detail, new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, Act_Dailipin_Liuyan_detail.class);
				intent.putExtra("id", data.agent_id);
				context.startActivity(intent);
			}
		});
	}

	@Override
	public boolean isEnabled(int position) {
		return false;
	}
}
